<template>
  <div class="app-container" v-loading="loading">
    <div class="head-container">
      <el-form
        ref="vForm"
        :model="form"
        :rules="rules"
        label-position="left"
        label-width="80px"
        size="medium"
        @submit.native.prevent
      >
        <el-row>
          <el-col :span="4" class="grid-cell">
            <div class="tip"><div>人员信息</div></div>
            <div style="margin-bottom: 10px;display: flex;align-items: center">
              <el-input placeholder="请输入体检编号" v-model="searchParams.checkCode" clearable class="input-with-select">
                <el-button slot="append" icon="el-icon-search" @click="SeachCheckcode"></el-button>
              </el-input>
              <div class="more" @click="dialogSearch=true">更多></div>
            </div>

            <div class="tip"><div>人员列表</div></div>
            <el-table
              ref="multiplePersonTable"
              border
              stripe
              :data="DataPersonlist"
              highlight-current-row
              @row-click="handleCurrentChange"
              max-height="500"
            >
              <el-table-column
                v-for="col in Personlist"
                :key="col.prop"
                :prop="col.prop"
                :label="col.label"
                :width="col.width"
                align="center"
              />
              <el-table-column label="状态" align="center" width="70">
                <template slot-scope="scope">
                  <span :style="{color:(scope.row.flowStatus== 1 ? 'green' : '#f52b2b')}">{{scope.row.flowStatus== 1 ? '已完成' : '未完成'}}</span>
                </template>
              </el-table-column>
            </el-table>
          </el-col>

          <el-col :span="20" class="grid-cell">
            <!-- 人员信息 -->
            <el-row>
              <el-col :span="4" class="grid-cell">
                <el-form-item label="" prop="pictureupload92945">
                  <div class="block">
                    <el-image
                      style="width: 85px; height: 100px"
                      :src="`data:image/png;base64,${form.headpicture}`"
                      fit="fill"
                    />
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="20" class="grid-cell">
                <el-descriptions title="人员信息">
                  <el-descriptions-item label="姓名">{{
                    this.form.name
                  }}</el-descriptions-item>
                  <el-descriptions-item label="性别">
                    <dict-tag :options="dict.type.sys_user_sex" :value="this.form.sex"/>
                  </el-descriptions-item>
                  <el-descriptions-item label="年龄">{{
                    this.form.age
                  }}</el-descriptions-item>
                  <el-descriptions-item label="单位名称">{{
                    this.form.companyName
                  }}</el-descriptions-item>
                  <el-descriptions-item label="在岗状态">
                    <dict-tag :options="dict.type.dime_physical_work" :value="this.form.workStatus"/>
                   </el-descriptions-item>
                  <el-descriptions-item label="危害因素">{{
                    this.form.touchHarms
                  }}</el-descriptions-item>
                </el-descriptions>
              </el-col>
            </el-row>
            <!-- 职业史 -->
            <el-row style="margin-left: 8px;margin-bottom:40px">
              <el-tabs v-model="activeName" style="height: 210px">
                <el-tab-pane label="职业史" name="first">
                  <div class="button-container" align="right">
                    <el-button
                      class="filter-item"
                      size="mini"
                      type="primary"
                      icon="el-icon-plus"
                      @click="handleCreateOccupations"
                      >新增
                    </el-button>
                  </div>
                  <el-table
                    ref="employmentmultipleTable"
                    border
                    stripe
                    :data="form.inquiryoccupations"
                    size="small"
                    height="160px"
                    style="width: 99%; margin-left: 4px"
                  >
                    <el-table-column type="index" label="No." :width="50" />
                    <el-table-column
                      :key="EmploymentcolumnList[0].prop"
                      :prop="EmploymentcolumnList[0].prop"
                      :label="EmploymentcolumnList[0].label"
                      :width="EmploymentcolumnList[0].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          is-range
                          v-model="scope.row.datefromto"
                          type="daterange"
                          class="full-width-input"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          clearable
                          style="width: 240px"
                        ></el-date-picker>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="EmploymentcolumnList[1].prop"
                      :prop="EmploymentcolumnList[1].prop"
                      :label="EmploymentcolumnList[1].label"
                      :width="EmploymentcolumnList[1].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.company"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="EmploymentcolumnList[2].prop"
                      :prop="EmploymentcolumnList[2].prop"
                      :label="EmploymentcolumnList[2].label"
                      :width="EmploymentcolumnList[2].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.workshop"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="EmploymentcolumnList[3].prop"
                      :prop="EmploymentcolumnList[3].prop"
                      :label="EmploymentcolumnList[3].label"
                      :width="EmploymentcolumnList[3].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.occupationtype"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="EmploymentcolumnList[4].prop"
                      :prop="EmploymentcolumnList[4].prop"
                      :label="EmploymentcolumnList[4].label"
                      :width="EmploymentcolumnList[4].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.harmfactor"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="EmploymentcolumnList[5].prop"
                      :prop="EmploymentcolumnList[5].prop"
                      :label="EmploymentcolumnList[5].label"
                      :width="EmploymentcolumnList[5].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.protectmeasure" placeholder="请选择防范措施">
                          <el-option
                            v-for="dict in dict.type.dime_inquiry_protectmeasure"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          ></el-option>
                        </el-select>
                      </template>
                    </el-table-column>

                    <el-table-column label="操作" align="center">
                      <template slot-scope="{ $index }">
                        <el-button
                          type="danger"
                          size="mini"
                          icon="el-icon-delete"
                          @click="employhandleDelete($index)"
                        />
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>

                <el-tab-pane label="既往病史" name="second">
                  <div class="button-container" align="right">
                    <el-button
                      class="filter-item"
                      size="mini"
                      type="primary"
                      icon="el-icon-plus"
                      @click="handleDiseasesCreate"
                      >新增
                    </el-button>
                  </div>
                  <el-table
                    ref="medicalmultipleTable"
                    border
                    stripe
                    :data="form.inquirydisease"
                    size="small"
                    height="160px"
                    style="width: 99%; margin-left: 4px"
                  >
                    <el-table-column type="index" label="No." :width="50" />

                    <el-table-column
                      :key="medicalcolumnList[0].prop"
                      :prop="medicalcolumnList[0].prop"
                      :label="medicalcolumnList[0].label"
                      :width="medicalcolumnList[0].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.diseaseName"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="medicalcolumnList[1].prop"
                      :prop="medicalcolumnList[1].prop"
                      :label="medicalcolumnList[1].label"
                      :width="medicalcolumnList[1].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.diagnoseDate"
                          type="date"
                          class="full-width-input"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          clearable
                          style="width: 240px"
                        ></el-date-picker>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="medicalcolumnList[2].prop"
                      :prop="medicalcolumnList[2].prop"
                      :label="medicalcolumnList[2].label"
                      :width="medicalcolumnList[2].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.diagnosis"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="medicalcolumnList[3].prop"
                      :prop="medicalcolumnList[3].prop"
                      :label="medicalcolumnList[3].label"
                      :width="medicalcolumnList[3].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.treatment"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="medicalcolumnList[4].prop"
                      :prop="medicalcolumnList[4].prop"
                      :label="medicalcolumnList[4].label"
                      :width="medicalcolumnList[4].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.returnTo"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>


                    <el-table-column label="操作" align="center">
                      <template slot-scope="{ $index }">
                        <el-button
                          type="danger"
                          size="mini"
                          icon="el-icon-delete"
                          @click="handleDiseasesDelete($index)"
                        />
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>

                <el-tab-pane label="急慢性职业病史" name="thrid">
                  <div class="button-container" align="right">
                    <el-button
                      class="filter-item"
                      size="mini"
                      type="primary"
                      icon="el-icon-plus"
                      @click="handlechronicCreate"
                      >新增
                    </el-button>
                  </div>

                  <el-table
                    ref="chronicmultipleTable"
                    border
                    stripe
                    :data="form.inquirychronicoccupationalhistory"
                    size="small"
                    height="160px"
                    style="width: 99%; margin-left: 4px"
                  >
                    <el-table-column type="index" label="No." :width="50" />
                    <el-table-column
                      :key="chroniccolumnList[0].prop"
                      :prop="chroniccolumnList[0].prop"
                      :label="chroniccolumnList[0].label"
                      :width="chroniccolumnList[0].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.diseasName"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>

                    <el-table-column
                      :key="medicalcolumnList[1].prop"
                      :prop="medicalcolumnList[1].prop"
                      :label="medicalcolumnList[1].label"
                      :width="medicalcolumnList[1].width"
                      align="center"
                    >

                        <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.diagnosisdate"
                          type="date"
                          class="full-width-input"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          clearable

                        ></el-date-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      :key="chroniccolumnList[2].prop"
                      :prop="chroniccolumnList[2].prop"
                      :label="chroniccolumnList[2].label"
                      :width="chroniccolumnList[2].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model="scope.row.company"
                          type="text"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      :key="chroniccolumnList[3].prop"
                      :prop="chroniccolumnList[3].prop"
                      :label="chroniccolumnList[3].label"
                      :width="chroniccolumnList[3].width"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-switch
                          v-model="scope.row.isheal"
                          active-color="#13ce66"
                          inactive-color="#ff4949"
                          active-value="1"
                          inactive-value="0"
                        >
                        </el-switch>
                      </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center">
                      <template slot-scope="{ $index }">
                        <el-button
                          type="danger"
                          size="mini"
                          icon="el-icon-delete"
                          @click="handlechronicDelete($index)"
                        />
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <div v-if="form.checkType!=='02'">
                  <el-tab-pane label="放射职业史" name="fourth">
                    <div class="button-container" align="right">
                      <el-button
                        class="filter-item"
                        size="mini"
                        type="primary"
                        icon="el-icon-plus"
                        @click="handleradiationCreate"
                      >新增
                      </el-button>
                      <el-button
                        class="filter-item"
                        size="mini"
                        type="primary"
                        icon="el-icon-plus"
                        @click="handleradiationImport"
                      >导入
                      </el-button>
                    </div>
                    <el-table
                      ref="radiationmultipleTable"
                      border
                      stripe
                      :data="form.inquiryradiationoccupations"
                      size="small"
                      height="160px"
                      style="width: 99%; margin-left: 4px"
                    >
                      <el-table-column type="index" label="No." :width="50" />

                      <el-table-column
                        :key="RadiationemploymentcolumnList[0].prop"
                        :prop="RadiationemploymentcolumnList[0].prop"
                        :label="RadiationemploymentcolumnList[0].label"
                        :width="RadiationemploymentcolumnList[0].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-date-picker
                            is-range
                            v-model="scope.row.datefromto"
                            type="daterange"
                            class="full-width-input"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            clearable
                            style="width: 240px"
                          ></el-date-picker>
                        </template>
                      </el-table-column>

                      <el-table-column
                        :key="RadiationemploymentcolumnList[1].prop"
                        :prop="RadiationemploymentcolumnList[1].prop"
                        :label="RadiationemploymentcolumnList[1].label"
                        :width="RadiationemploymentcolumnList[1].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.company"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[2].prop"
                        :prop="RadiationemploymentcolumnList[2].prop"
                        :label="RadiationemploymentcolumnList[2].label"
                        :width="RadiationemploymentcolumnList[2].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.workshop"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[3].prop"
                        :prop="RadiationemploymentcolumnList[3].prop"
                        :label="RadiationemploymentcolumnList[3].label"
                        :width="RadiationemploymentcolumnList[3].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.occupationtype"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[4].prop"
                        :prop="RadiationemploymentcolumnList[4].prop"
                        :label="RadiationemploymentcolumnList[4].label"
                        :width="RadiationemploymentcolumnList[4].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.occupationexposure"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[5].prop"
                        :prop="RadiationemploymentcolumnList[5].prop"
                        :label="RadiationemploymentcolumnList[5].label"
                        :width="RadiationemploymentcolumnList[5].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.radiationcategory"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[6].prop"
                        :prop="RadiationemploymentcolumnList[6].prop"
                        :label="RadiationemploymentcolumnList[6].label"
                        :width="RadiationemploymentcolumnList[6].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.workhours"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[7].prop"
                        :prop="RadiationemploymentcolumnList[7].prop"
                        :label="RadiationemploymentcolumnList[7].label"
                        :width="RadiationemploymentcolumnList[7].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.exposuretotal"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        :key="RadiationemploymentcolumnList[8].prop"
                        :prop="RadiationemploymentcolumnList[8].prop"
                        :label="RadiationemploymentcolumnList[8].label"
                        :width="RadiationemploymentcolumnList[8].width"
                        align="center"
                      >
                        <template slot-scope="scope">
                          <el-input
                            v-model="scope.row.exposureexcess"
                            type="text"
                          ></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column label="操作" align="center" width="50">
                        <template slot-scope="{ row, $index }">
                          <el-button
                            type="danger"
                            size="mini"
                            icon="el-icon-delete"
                            @click="handleRadiatioDelete($index)"
                          />
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-tab-pane>
                  <el-tab-pane label="放射史其他" name="five">
                    <div class="button-container" align="right">
                      <el-row>
                        <el-col :span="24" class="grid-cell">
                          <el-form-item
                            label="配偶接触放射情况"
                            prop="personal"
                            class="label-right-align"
                            label-width="140px"
                          >
                            <el-input
                              v-model="form.inquiryradiationother.spouseradiation"
                              size="mini"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>

                          <el-form-item
                            label="配偶职业及健康状况"
                            prop="personal"
                            class="label-right-align"
                            label-width="140px"
                          >
                            <el-input
                              v-model="form.inquiryradiationother.spousehealth"
                              size="mini"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>

                          <el-form-item
                            label="剂量检测单位"
                            prop="personal"
                            class="label-right-align"
                            label-width="140px"
                          >
                            <el-input
                              v-model="form.inquiryradiationother.radiationdetection"
                              size="mini"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>

                          <el-form-item
                            label="知识培训单位"
                            prop="personal"
                            class="label-right-align"
                            label-width="140px"
                          >
                            <el-input
                              v-model="form.inquiryradiationother.trainingorg"
                              size="mini"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                      </el-row>
                    </div>
                  </el-tab-pane>
                </div>
              </el-tabs>
            </el-row>
            <!-- 个人史 -->
            <el-row style="margin:0 10px 0px 8px">
              <el-tabs v-model="PersonalName">
                  <el-tab-pane label="个人史" name="first">
                    <el-row style="margin-bottom: 4px">
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="吸烟情况"
                          prop="inquiryitems.smoke"
                          class="label-right-align"
                        >
                          <el-select
                            v-model="form.inquiryitems.smoke"
                            style="width: 90%"
                            @change="changeSmoke($event)"
                          >
                            <el-option
                              v-for="dict in dict.type.dime_physical_somke"
                              :key="dict.value"
                              :label="dict.label"
                              :value="dict.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="吸烟量(支)"
                          prop="inquiryitems.smokequantity"
                          class="label-right-align"
                          label-width="90px"
                        >
                          <el-input
                            style="width: 90%"
                            v-model="form.inquiryitems.smokequantity"
                            type="text"
                            clearable
                            suffix-icon="支/天"
                          >
                          </el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="烟龄(年)"
                          prop="inquiryitems.smokeyears"
                          style="width: 90%"
                          class="label-right-align"
                        >
                          <el-input-number v-model="form.inquiryitems.smokeyears"  :min="0" :step="1" :precision="0"></el-input-number>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="烟龄(月)"
                          prop="inquiryitems.smokemonths"
                          class="label-right-align"
                        >
                          <el-input-number v-model="form.inquiryitems.smokemonths"  :min="0" :max="12" :step="1" :precision="0"></el-input-number>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="饮酒情况"
                          prop="drink"
                          class="label-right-align"
                        >
                          <el-select
                            v-model="form.inquiryitems.drink"
                            style="width: 90%"
                            @change="changeDrink($event)"
                          >
                            <el-option
                              v-for="dict in dict.type.dime_physical_drink"
                              :key="dict.value"
                              :label="dict.label"
                              :value="dict.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="饮酒量(ml)"
                          prop="drinkquantity"
                          label-width="90px"
                          class="label-right-align"
                        >
                          <el-input
                            v-model="form.inquiryitems.drinkquantity"
                            type="text"
                            style="width: 90%"
                            clearable
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="酒龄(年)"
                          prop="drinkyears"
                          style="width: 90%"
                          class="label-right-align"
                        >
                          <el-input-number v-model="form.inquiryitems.drinkyears"  :min="0" :step="1" :precision="0"></el-input-number>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="酒龄(月)"
                          prop="drinkmonths"
                          class="label-right-align"
                        >
                          <el-input-number v-model="form.inquiryitems.drinkmonths"  :min="0" :max="12" :step="1" :precision="0"></el-input-number>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="24" class="grid-cell">
                        <el-form-item
                          label="个人史"
                          prop="personal"
                          class="label-right-align"
                        >
                          <el-input
                            v-model="form.inquiryitems.personal"
                            placeholder="请输入个人史"
                            type="text"
                            clearable
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col>
                        <el-form-item label="家族病史" prop="family" class="label-right-align">
                          <el-input
                            v-model="form.inquiryitems.family"
                            placeholder="请输入家族病史"
                            type="text"
                            clearable
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col>
                        <el-form-item label="其他" prop="other" class="label-right-align">
                              <el-input
                                v-model="form.inquiryitems.other"
                                type="text"
                                placeholder="请输入其他"
                                clearable
                              ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <div v-show="this.form.sex=='FEMALE'">
                      <div class="static-content-item">
                        <el-divider direction="horizontal">女性</el-divider>
                      </div>
                      <el-row>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="初潮(岁)"
                            prop="menstrbegin"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.menstrbegin"
                              size="mini"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="经期(天)"
                            prop="menstrlen"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.menstrlen"
                              size="mini"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="周期(天)"
                            prop="menstrcycle"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.menstrcycle"
                              type="text"
                              size="mini"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="停经(岁)"
                            prop="menstrend"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.menstrend"
                              type="text"
                              size="mini"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="经期"
                            prop="menstrcome"
                            class="label-right-align"
                          >
                            <el-radio-group
                              v-model="form.inquiryitems.menstrcome"
                            >
                              <el-radio
                                v-for="(item, index) in menstrcomeOptions"
                                :key="index"
                                :label="item.value"
                                :disabled="item.disabled"
                                style="
                                 {
                                  display: inline;
                                }
                              "
                              >{{ item.label }}</el-radio
                              >
                            </el-radio-group>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell"> </el-col>
                      </el-row>
                      <el-row>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="子女数"
                            prop="childrencount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.childrencount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="流产胎次"
                            prop="abortiontimes"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.abortiontimes"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="早产胎次"
                            prop="prematuretimes"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.prematuretimes"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="死产胎次"
                            prop="reproducedied"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.reproducedied"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="异产胎次"
                            prop="mostercount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.mostercount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell"> </el-col>
                      </el-row>
                      <el-row>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="孕次"
                            prop="graviditycount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.graviditycount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="活产胎次"
                            prop="livebrithcount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.livebrithcount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="畸胎"
                            prop="teratomacount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.teratomacount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="多胎"
                            prop="mostcount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.mostcount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell">
                          <el-form-item
                            label="异位妊娠"
                            prop="eccyesiscount"
                            class="label-right-align"
                          >
                            <el-input
                              v-model="form.inquiryitems.eccyesiscount"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="4" class="grid-cell"> </el-col>
                      </el-row>
                      <el-row>
                        <el-col>
                          <el-form-item
                            label="不孕不育情况"
                            prop="infertility"
                            class="label-right-align"
                            label-width="100px"
                          >
                            <el-input
                              v-model="form.inquiryitems.infertility"
                              type="text"
                              clearable
                            ></el-input>
                          </el-form-item>
                        </el-col>
                      </el-row>
                    </div>
                    <el-row>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="男孩"
                          prop="boys"
                          class="label-right-align"
                        >
                          <el-input
                            v-model="form.inquiryitems.boys"
                            type="text"
                            clearable
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="出生日期"
                          prop="boybrithdays"
                          class="label-right-align"
                        >
                          <el-date-picker
                            v-model="form.inquiryitems.boybrithdays"
                            type="date"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd">
                          </el-date-picker>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="女孩"
                          prop="girls"
                          class="label-right-align"
                        >
                          <el-input
                            v-model="form.inquiryitems.girls"
                            type="text"
                            clearable
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" class="grid-cell">
                        <el-form-item
                          label="出生日期"
                          prop="girlbrithdays"
                          class="label-right-align"
                        >
                          <el-date-picker
                            v-model="form.inquiryitems.girlbrithdays"
                            type="date"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd">
                          </el-date-picker>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="24" class="grid-cell">
                        <el-form-item
                          label="子女健康情况"
                          prop="childhealth"
                          class="label-right-align"
                          label-width="100px"
                        >
                          <el-input
                            v-model="form.inquiryitems.childhealth"
                            type="text"
                            clearable
                            placeholder="请输入子女健康情况"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col>
                        <el-form-item
                          label="现患疾病"
                          class="label-right-align"
                          prop="CurrentDiseases"
                        >
                          <el-select
                            v-model="form.inquirycurrentdiseases"
                            multiple
                            filterable
                            allow-create
                            default-first-option
                            placeholder="请选择疾病"
                            style="width: 100%"
                            @change="CurrentDiseaseschange($event)"
                          >
                            <el-option
                              v-for="item in Diseasesoptions"
                              :key="item.id"
                              :label="item.dKey"
                              :value="item.id"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col>
                        <el-form-item
                          label="症状"
                          prop="symptom"
                          class="label-right-align"
                        >
                          <el-select
                            v-model="form.inquirysymptom"
                            multiple
                            filterable
                            allow-create
                            default-first-option
                            placeholder="请选择症状"
                            style="width: 100%"
                          >
                            <el-option
                              v-for="item in symptomoptions"
                              :key="item.id"
                              :label="item.symptomName"
                              :value="item.id"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-tab-pane>

                  <el-tab-pane label="签名" name="second">
                    <el-form-item
                      label="签名"
                      class="label-right-align"
                      prop="CurrentDiseases"
                    >
                      <div>
<!--                        <vue-esign style="border:2px solid #000;margin-bottom: 8px" ref="esign" :width="800" :height="400" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" />-->
                        <div style="width: 700px;height: 340px;border:1px solid #2b2b2b;margin-bottom: 8px;background-color: papayawhip">
                          <img ref="img_sign_result" :src="form.inquirysign.signsoure"
                               style="width: 100%;height: 100%" v-if="form.inquirysign.signsoure"/>
                        </div>
                        <el-button size="medium" @click="beginSign" type="primary">开始签名</el-button>
                        <el-button size="medium" @click="clearSign" type="success">清空画板</el-button>
                      </div>
                    </el-form-item>
                  </el-tab-pane>
                </el-tabs>
            </el-row>
            <!-- 个人信息 -->
            <div style="margin:0 10px 0px 8px">
              <el-divider content-position="left"
              >个人信息</el-divider
              >
              <el-row>
                <el-col :span="8">
                  <el-form-item
                    label="部门"
                    prop="personal"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.dept"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    label="工种"
                    prop="personal"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.jobType"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    label="工号"
                    prop="personal"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.empNo"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item
                    label="总工龄(年)"
                    prop="personal"
                    label-width="100px"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.workYears"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    label="总工龄(月)"
                    label-width="100px"
                    prop="personal"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.workMonths"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    label="参加工作时间"
                    label-width="120px"
                    prop="startworkDate"
                    class="label-right-align"
                  >
                    <el-date-picker
                      v-model="form.startworkDate"
                      type="date"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item
                    label="接害工龄(年)"
                    prop="personal"
                    label-width="100px"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.touchYears"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    label="接害工龄(月)"
                    prop="personal"
                    label-width="100px"
                    class="label-right-align"
                  >
                    <el-input
                      v-model="form.touchMonths"
                      type="text"
                      clearable
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    label="接触危害时间"
                    label-width="120px"
                    prop="touharmDate"
                    class="label-right-align"
                  >
                    <el-date-picker
                      v-model="form.touharmDate"
                      type="date"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div slot="footer" align="right" style="padding: 10px 10px 0 0" v-if="form.dimePhysicalflow.flowStatus!==''">
      <el-button size="medium" type="text" @click="resetForm('form')"
      >重置</el-button
      >
      <el-button size="medium" type="danger" @click="revokeForm" v-if="form.dimePhysicalflow.flowStatus==1"
      >撤销</el-button
      >
      <el-button
        v-if="form.dimePhysicalflow.flowStatus==0"
        v-loading="formLoading"
        size="medium"
        type="primary"
        @click="submitForm"
      >确认</el-button
      >
    </div>
    <el-dialog
      :visible.sync="dialogSearch"
      title="更多搜索条件"
      @close="dialogSearch=false"
      width="650px"
    >
      <el-form :model="searchParams" ref="searchForm" label-position="right" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="体检编号" prop="checkCode">
              <el-input
                v-model="searchParams.checkCode"
                placeholder="请输入体检编号"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="体检状态" prop="completStatus">
              <el-select v-model="searchParams.flowStatus" placeholder="请选择体检状态">
                <el-option
                  key="0"
                  label="未完成"
                  value="0"
                ></el-option>
                <el-option
                  key="1"
                  label="已完成"
                  value="1"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="登记日期" prop="registerDate">
          <el-date-picker
            style="width: 100%"
            v-model="registerDate"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="体检日期" prop="physicalDate">
          <el-date-picker
            style="width: 100%"
            v-model="physicalDate"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="单位名称" prop="companyName">
          <el-input
            v-model="searchParams.companyName"
            placeholder="请输入单位名称"
            clearable
          />
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="体检类型" prop="checkType">
              <el-select v-model="searchParams.checkType" placeholder="请选择体检类型">
                <el-option
                  v-for="dict in dict.type.dime_physical_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="在岗状态" prop="workStatus">
              <el-select v-model="searchParams.workStatus" placeholder="请选择在岗状态" clearable>
                <el-option
                  v-for="dict in dict.type.dime_physical_work"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div align="right" style="margin-top:20px">
        <el-button icon="el-icon-refresh" size="medium" @click="resetSearch"
        >重置</el-button
        >
        <el-button
          icon="el-icon-search"
          size="medium"
          type="primary"
          @click="handleSearch"
        >确认</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import TablecolumnList from "../tablecolumn.js";
import { getTodayRegisterinquirylist,getBasediseaselist,getBasesymptomlist,Saveinquiry,getRegisterinquiryByPhysical,getRegisterinquiryBywhere,Revokeinquiry } from '@/api/physical/physicalinquiry'
import MyTreeSelect from '@/views/components/my-tree-select'

const defaultForm = {
  address: "",
  age: 0,
  baseCompanyId: "",
  basePackageId: "",
  birthday: "",
  channel: "",
  checkCode: "",
  checkDate: "",
  checkResult: "",
  checkType: "",
  combLack: "",
  companyName: "",
  completStatus: "",
  dept: "",
  empNo: "",
  harmfacter: "",
  headUrl: "",
  healthSuggestion: "",
  id: "",
  idNo: "",
  idNoType: "",
  inquirychronicoccupationalhistory: [],
  inquirycurrentdiseases: [],
  inquirydisease: [],
  inquiryitems: {
    abortiontimes: 0,
    boybrithdays: "",
    boys: 0,
    childhealth: "",
    childrencount: 0,
    drink: "不饮酒",
    drinkquantity: 0,
    drinkyears: 0,
    drinkmonths: 0,
    eccyesiscount: 0,
    family: "",
    girlbrithdays: "",
    girls: 0,
    graviditycount: 0,
    id: "",
    infertility: "",
    livebrithcount: 0,
    menstrbegin: 0,
    menstrcome: 1,
    menstrcycle: 0,
    menstrend: 0,
    menstrlen: 0,
    mostcount: 0,
    other: "",
    params: {},
    personal: "",
    physicalRegisterId: "",
    prematuretimes: 0,
    remark: "",
    reproducedied: 0,
    mostercount: 0,
    smoke: "从不吸",
    smokequantity: 0,
    smokeyears:0,
    smokemonths:0,
    teratomacount:"",
  },
  inquiryoccupations: [],
  inquiryradiationoccupations: [],
  inquiryradiationother: {
    doctorId: "",
    doctorName: "",
    education: "",
    id: "",
    marriagedate: "",
    params: {},
    physicalRegisterId: "",
    radiationdetection: "",
    remark: "",
    spousehealth: "",
    spouseradiation: "",
    trainingorg: "",
  },
  inquirysign: {
    id: "",
    params: {},
    physicalRegisterId: "",
    remark: "",
    signsoure: "",
  },
  dimePhysicalflow: {
    flowStatus: "",
  },
  inquirysymptom: [],
  isValid: 0,
  jobType: "",
  lastCheckCode: "",
  mainCheckDate: "",
  mainCheckDoctor: "",
  mainConclusion: "",
  marriage: "",
  name: "",
  nation: "",
  nationality: "",
  needAsk: "",
  packageName: "",
  params: {},
  password: "",
  personType: "",
  phone: "",
  platformTag: "",
  reCheckTag: "",
  registerDate: "",
  remark: "",
  reportPrintDate: "",
  reportPrinter: "",
  serviceUid: "",
  sex: "",
  shopCode: "",
  soaOrderNo: "",
  socialCode: "",
  takeReportType: "",
  touchHarms: "",
  touchMonths: 0,
  touchYears: 0,
  workMonths: 0,
  startworkDate:"",
  touharmDate:"",
  workStatus: "",
  workYears: 0
};
export default {
  dicts: ['sys_user_sex','dime_physical_work','dime_inquiry_protectmeasure','dime_physical_jobtype','dime_physical_type','dime_physical_somke','dime_physical_drink'],
  components: { MyTreeSelect },
  props: {},
  data() {
    return {
      plugin: null,
      registerDate:'',
      physicalDate:'',
      searchParams:{
        flowStatus:'',
        checkCode:'',
        registerbegineDate:'',
        registerendDate:'',
        physicalbegineDate:'',
        physicalendDate:'',
        companyName:'',
        checkType:'',
        workStatus:''
      },
      dialogSearch: false,
      choosedPersonInfo:{},
      loading:false,
      checkCode:'',
      harmtList:[],
      formData: {
        pictureupload92945: null,
        input120175: "",
        //CurrentDiseases: [],
      },
      symptomoptions:[],
      rules: {
        'inquiryitems.smoke': [
          { required: true, message: "吸烟情况不能为空", trigger: ['change', 'blur'] }
        ],
        'inquiryitems.smokequantity': [
          { required: true, message: "吸烟量不能为空", trigger: ['change', 'blur'] }
        ],
        'inquiryitems.smokeyears': [
          { required: true, message: "烟龄年不能为空", trigger: ['change', 'blur'] }
        ],
        'inquiryitems.smokemonths': [
          { required: true, message: "烟龄月不能为空", trigger: ['change', 'blur'] }
        ],
      },
      formLoading: false,
      EmploymentcolumnList: TablecolumnList.EmploymentcolumnList,
      medicalcolumnList: TablecolumnList.medicalcolumnList,
      Personlist: TablecolumnList.Personlist,
      RadiationemploymentcolumnList: TablecolumnList.RadiationemploymentcolumnList,
      chroniccolumnList: TablecolumnList.chroniccolumnList,
      url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
      form: JSON.parse(JSON.stringify(defaultForm)),
      dialogFormVisible: false,
      multipleSelection: [],
      SubsSelection: [],
      itemSelection: [],
      formTitle: "",
      search: "",
      DataPersonlist: [],
      activeName: "first",
      diseaseName: "first",
      PersonalName: "first",
      Diseasesoptions: [],
      menstrcomeOptions: [
        {
          value: 0,
          label: "是",
        },
        {
          label: "否",
          value: 1,
        },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {
    this.InitPersonList();
    this.InitDatas();
  },
  mounted() {
    this.initPlugin()
  },
  methods: {
    initPlugin() {
      if (!!this.plugin) {
        this.plugin.DestroyPlugin();
      }
      this.plugin = new PluginNSV();
      this.plugin.InitPlugin((state)=> {
        if (state === 1) {
          //set pen size
          this.plugin.setPenSizeRange(1,5,null);
          //set pen color
          this.plugin.setPenColor(0,0,0,null);
          //sign mode
          this.plugin.setDisplayMapMode(1,null);
          console.log("initialize plugin OK.");
        } else {
          console.log("initialize plugin fails.");
        }
      });

      /*confirm event*/
      this.plugin.onConfirm = ()=> {
        this.saveSignToBase64();
        this.endSign();
      };
      /*clear event*/
      this.plugin.onClear = ()=> {
        this.clearSign();
      };
      /*cancel event*/
      this.plugin.onCancel = ()=> {
        this.endSign();
      };
    },
    clearSign() {
      this.form.inquirysign.signsoure = ''
      if (!!this.plugin) {
        //Reset the signature panel.
        this.plugin.clearSign((state, args)=> {
          if (state) {

          } else {
            console.log("clearSign error,description:" + args[0]);
          }
        });
      }
    },
    beginSign() {
      if (!!this.plugin) {
        this.plugin.beginSign((state, args)=> {
          if (state) {

          }
          else {
            this.$message.error("启动签名版失败");
            console.log("beginSign error,description:" + args[0]);
          }
        });
      }
    },
    endSign() {
      if (!!this.plugin) {
        /* plugin.endSign(null);*/
        this.plugin.endSign((state, args)=> {
          if (state) {

          }
          else {
            console.log("endSign error,description:" + args[0]);
          }
        });
      }
    },
    saveSignToBase64() {
      if (!!this.plugin) {
        //Get the plugin's signature image data.
        this.plugin.saveSignToBase64(/*615, 272*/0,0, (state, args)=> {
          if (state) {
            let img_base64_data = args[0];
            //Show the signature image.
            let img_base64 = "data:image/png;base64,"+img_base64_data;
            console.log(img_base64)
            this.form.inquirysign.signsoure = img_base64
            console.log("saveSignToBase64 OK");
            //Submit the signature base64 string to the server
            //...
          }else {
            console.log("saveSignToBase64 error,description:" + args[0]);
          }
        });
      }
    },
    changeSmoke(val){
    if(val=='从不吸'){
      this.form.inquiryitems.smokequantity=0,
      this.form.inquiryitems.smokeyears=0,
        this.form.inquiryitems.smokemonths=0
     }else{
      this.form.inquiryitems.smokequantity="",
      this.form.inquiryitems.smokeyears=undefined,
        this.form.inquiryitems.smokemonths=undefined
     }
    },
    changeDrink(val){
      if(val=='不饮酒'){
        this.form.inquiryitems.drinkquantity=0,
          this.form.inquiryitems.drinkyears=0,
          this.form.inquiryitems.drinkmonths=0
      }else{
          this.form.inquiryitems.drinkquantity="",
          this.form.inquiryitems.drinkyears=undefined,
          this.form.inquiryitems.drinkmonths=undefined
      }
    },
    resetSearch() {
      this.registerDate='',
        this.physicalDate='',
        this.searchParams={
          checkCode:'',
          registerbegineDate:'',
          registerendDate:'',
          physicalbegineDate:'',
          physicalendDate:'',
          companyName:'',
          checkType:'',
          workStatus:''
        }
    },
    resetForm() {
      this.form = JSON.parse(JSON.stringify(defaultForm))
    },
    handleCurrentChange(val) {
      this.$refs.vForm.clearValidate()
      this.choosedPersonInfo=val
      this.loading=true
      getRegisterinquiryByPhysical(val).then(response => {
        if(response.dimePhysicalflow.flowStatus==1){
          response.inquiryoccupations.forEach(item=>{
            item.datefromto= item.datefromto.split(',')
          })
          response.inquiryradiationoccupations.forEach(item=>{
            item.datefromto= item.datefromto.split(',')
          })
          response.inquirysymptom = response.inquirysymptom.map(item=>{
            return item.symptomId
          })
        }
        if(!response.inquiryitems) {
          response.inquiryitems = JSON.parse(JSON.stringify(defaultForm.inquiryitems))
        }
        if(!response.inquiryradiationother) {
          response.inquiryradiationother = JSON.parse(JSON.stringify(defaultForm.inquiryradiationother))
        }
        if(!response.inquirysign) {
          response.inquirysign = JSON.parse(JSON.stringify(defaultForm.inquirysign))
        }
        this.form= response
      }).finally(()=>{
        this.loading=false
      });
    },
    SeachCheckcode() {
      this.handleSearch()
    },
    handleSearch(){
      this.searchParams.registerbegineDate=this.registerDate[0]
      this.searchParams.registerendDate=this.registerDate[1]
      this.searchParams.physicalbegineDate=this.physicalDate[0]
      this.searchParams.physicalendDate=this.physicalDate[1]
      this.loading=true
      getRegisterinquiryBywhere(this.searchParams).then(response => {
        this.DataPersonlist = response;
        this.dialogSearch=false
      }).finally(()=>{
        this.loading=false
      });
    },
    InitPersonList() {
      this.loading=true,
      getTodayRegisterinquirylist().then(response => {
        this.DataPersonlist = response;
      }).finally(()=>{
        this.loading=false
      });
    },

 InitDatas() {
      //现患疾病
   getBasediseaselist({pageNum: 1,
     pageSize: 1000}).then(response => {
     this.Diseasesoptions = response.rows;
   });

      //症状
   getBasesymptomlist({pageNum: 1,
     pageSize: 1000}).then(response => {
     this.symptomoptions = response.rows;
   });
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },

    handleCreate() {
      this.formTitle = "新增表单";
      this.isEdit = false;
      this.dialogFormVisible = true;
    },

    handleCreateOccupations() {
      let newValue = {
        company: this.form.companyName,
        datefromto: "",
        harmfactor: this.form.touchHarms,
        id: "",
        occupationtype: this.form.jobType,
        params: {},
        physicalRegisterId: "",
        protectmeasure: "",
        remark: "",
        workshop: this.form.dept
      };
      //添加新的行数
      this.form.inquiryoccupations.push(newValue);
    },
    handleradiationCreate() {
      let newValue = {
        company: "",
        datefromto: "",
        exposureexcess: "",
        exposuretotal: "",
        id: "",
        occupationexposure: "",
        occupationtype: "",
        params: {},
        physicalRegisterId: "",
        radiationcategory: "",
        remark: "",
        workhours: "",
        workshop: ""
      };
      //添加新的行数
      this.form.inquiryradiationoccupations.push(newValue);
    },

    handleradiationImport() {
      let newValue = {
        id: "",
        machinetag: "",
        datefromto: "",
        datefrom:"",
        dateto:"",
        company: this.form.companyname,
        workshop: this.form.dept,
        occupationtype: this.form.jobtype,
        occupationexposure: "",
        occupationexposurecode: "",
        radiationcategory: "",
        workhours: "",
        exposuretotal: "",
        exposureexcess: "",
        pinyincode: "",
        remark: "",
        sn: 0,
        modifytimes: 0,
        updatecode: "",
        uploadtag: 0,
      };
      //添加新的行数
      this.form.inquiryradiationoccupations.push(newValue);
    },

    handleDiseasesCreate() {
      let newValue = {
        diagnoseDate: "",
        diagnosis: "",
        diseaseName: "",
        doctorId: "",
        doctorName: "",
        id: "",
        occupational: "",
        params: {},
        physicalRegisterId: "",
        remark: "",
        returnTo: "",
        treatment: "",
      };
      //添加新的行数
      this.form.inquirydisease.push(newValue);
    },

    handlechronicCreate() {
      let newValue = {
        company: "",
        diagnosisdate: "",
        diseasName: "",
        diseaseId: "",
        doctorId: "",
        doctorName: "",
        id: "",
        isheal: 0,
        params: {},
        physicalRegisterId: "",
        remark: "",
      };
      this.form.inquirychronicoccupationalhistory.push(newValue);
    },

    employhandleDelete(index) {
      this.form.inquiryoccupations.splice(index, 1);
    },
    handleRadiatioDelete(index) {
      this.form.inquiryradiationoccupations.splice(index, 1);
    },
    handleDiseasesDelete(index) {
      this.form.inquirydisease.splice(index, 1);
    },

    handlechronicDelete(index) {
      this.form.inquirychronicoccupationalhistory.splice(index, 1);
    },

    CurrentDiseaseschange(event) {
      this.form.inquirycurrentdiseases = [];
      this.Diseasesoptions.forEach((x) => {
        if (event.includes(x.id)) {
          this.form.inquirycurrentdiseases.push({
            id: null,
            diseasename: x.dKey,
            dicguid: x.id,
          });
        }
      });
    },
    revokeForm() {
      this.$confirm("确定是否撤销", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          Revokeinquiry(this.choosedPersonInfo).then(response => {
            this.$notify({
              title: "成功",
              message: "撤销成功",
              type: "success",
              duration: 2000,
            });
            this.InitPersonList()
            this.form.dimePhysicalflow.flowStatus=0
          })
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    submitForm() {
      if (this.form.id == "" || this.form.id == undefined) {
        this.$message({
          message: "人员不能为空",
          type: "warning",
        });
        return;
      }
      if(this.form.inquiryitems.smoke != '从不吸' && this.form.inquiryitems.smokeyears == 0 && this.form.inquiryitems.smokemonths == 0) {
        this.$message({
          message: "烟龄年和月不能都为0",
          type: "warning",
        });
        return;
      }
      if(this.form.inquiryitems.drink != '不饮酒' && this.form.inquiryitems.drinkyears == 0 && this.form.inquiryitems.drinkmonths == 0) {
        this.$message({
          message: "酒龄年和月不能都为0",
          type: "warning",
        });
        return;
      }
      let submitForm = JSON.parse(JSON.stringify(this.form))
      if(submitForm.inquiryoccupations) {
        for(let i = 0;i < submitForm.inquiryoccupations.length; i++) {
          let item = submitForm.inquiryoccupations[i]
          if(!item.datefromto){
            this.$message({
              message: "请选择起止日期",
              type: "warning",
            });
            return;
          }else{
            item.datefromto = item.datefromto.join(',')
          }
        }
      }
      if(submitForm.inquiryradiationoccupations) {
        for(let i = 0;i < submitForm.inquiryradiationoccupations.length; i++) {
          let item = submitForm.inquiryradiationoccupations[i]
          if(!item.datefromto){
            this.$message({
              message: "请选择起止日期",
              type: "warning",
            });
            return;
          }else{
            item.datefromto = item.datefromto.join(',')
          }
        }
      }
      let inquirysymptom = submitForm.inquirysymptom;
      submitForm.inquirysymptom = []
      this.symptomoptions.forEach((x) => {
        if (inquirysymptom.includes(x.id)) {
          submitForm.inquirysymptom.push({
            doctorId: "",
            doctorName: "",
            id: "",
            params: {},
            physicalRegisterId: "",
            remark: "",
            symptomId: x.id,
            symptomName: x.symptomName,
          });
        }
      });
      if(submitForm.inquirysymptom && submitForm.inquirysymptom.length == 0) {
        submitForm.inquirysymptom = null
      }
      if(submitForm.inquiryoccupations && submitForm.inquiryoccupations.length == 0) {
        submitForm.inquiryoccupations = null
      }
      if(submitForm.inquirydisease && submitForm.inquirydisease.length == 0) {
        submitForm.inquirydisease = null
      }
      if(submitForm.inquirycurrentdiseases && submitForm.inquirycurrentdiseases.length == 0) {
        submitForm.inquirycurrentdiseases = null
      }
      if(submitForm.inquirychronicoccupationalhistory && submitForm.inquirychronicoccupationalhistory.length == 0) {
        submitForm.inquirychronicoccupationalhistory = null
      }
      if(submitForm.inquiryradiationoccupations && submitForm.inquiryradiationoccupations.length == 0) {
        submitForm.inquiryradiationoccupations = null
      }
      this.$refs["vForm"].validate(valid => {
        if(valid) {
          this.loading = true;
          Saveinquiry(submitForm).then(response => {
            this.$modal.msgSuccess("保存成功");
            this.InitPersonList()
            this.handleCurrentChange(this.choosedPersonInfo)
          }).finally(()=>{
            this.loading = false;
          });
        }
      })

    },
  },
};
</script>

<style scoped lang="scss">
.head-container{
  height: calc(100vh - 180px);
  overflow-y: auto;
}
.tip {
  padding: 10px 10px;
  background-color: #ecf8ff;
  border-radius: 4px;
  border-left: 5px solid #50bfff;
  margin: 5px 0;
}
.more{
  font-size: 12px;
  color: #1890ff;
  margin-left: 4px;
  white-space: nowrap;
  cursor:pointer;
}
.button-container {
  padding: 2px 10px 3px 2px;
}
.el-form-item {
  margin-bottom: 14px !important;
}

.el-input-number.full-width-input,
.el-cascader.full-width-input {
  width: 100% !important;
}

.el-form-item--medium {
  .el-radio {
    line-height: 36px !important;
  }

  .el-rate {
    margin-top: 8px;
  }
}

.el-form-item--small {
  .el-radio {
    line-height: 32px !important;
  }

  .el-rate {
    margin-top: 6px;
  }
}
.el-form-item--mini {
  .el-radio {
    line-height: 28px !important;
  }
  .el-rate {
    margin-top: 4px;
  }
}
.clear-fix:before,
.clear-fix:after {
  display: table;
  content: "";
}
.clear-fix:after {
  clear: both;
}
.float-right {
  float: right;
}
</style>

<style lang="scss" scoped>
div.table-container {
  table.table-layout {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    td.table-cell {
      display: table-cell;
      height: 36px;
      border: 1px solid #e1e2e3;
    }
  }
}

.label-left-align ::v-deep .el-form-item__label {
  text-align: left;
}

.label-center-align ::v-deep .el-form-item__label {
  text-align: center;
}

.label-right-align ::v-deep .el-form-item__label {
  text-align: right;
}

.static-content-item {
  min-height: 20px;
  display: flex;
  align-items: center;

  ::v-deep .el-divider--horizontal {
    margin: 0;
  }
}
</style>
